<template>
	<view class="conter">

		<!-- <header-box :title="title"></header-box> -->


		<view class="header" style="color: #000000;" @tap="goBack(id)">
			<view class="arrow">
			</view>
			<view class="title">
				{{title}}
			</view>
		</view>


		<!-- <view class="" style="padding: 0 30rpx;">
			<u-search :show-action="true" action-text="搜索" placeholder="搜索关键字或日期..." v-model="keyword" :animation="true"></u-search>
		</view> -->




		<view class="" style="padding: 0 30rpx;">

			<u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id" @click="click" @open="open"
			 :options="options">
				<view class="item u-border-bottom" @click="goinfo(item.hotel_details_id,item.id)">
					<!-- <view class=""> -->
						<image class="w220 h220 r10" mode="aspectFill" :src="imgs + item.image" />
					<!-- </view> -->

					<!-- 此层wrap在此为必写的，否则可能会出现标题定位错误 -->
					<view class="title-wrap">
						<text class="title u-line-2" style="margin-left: 10rpx;">{{ item.title }}</text>
						<!-- <u-icon name="clock" color="#717171" size="28"></u-icon> -->
						<text class="cuIcon-countdown" style="margin-left: 10rpx;">{{item.createdate}}</text>
						<view class="cuIcon-sponsor"
							style="margin-left: 10rpx;">
							购买价格：
						<text class="" style="color: #FF0000;">{{item.money}}</text>
						</view>
						<text class="cuIcon-location" style="margin-left: 10rpx; white-space: nowrap;">{{item.address}}</text>
					</view>
				</view>
			</u-swipe-action>
		</view>




	</view>
</template>

<script>
	// this.uid = uni.getStorageSync('uid');
	
	export default {
		components: {},
		data() {
			return {
				title: '我的订单',
				count: 4,
				value: 2,
				img: [],
				keyword: '',
				list: [],
				disabled: false,
				btnWidth: 180,
				show: false,
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#dd524d'
					}
				}],
				uid: '',
				imgs: this.$images,
			}
		},
		onLoad() {},
		onShow() {
			this.userInfo()
		},
		onReachBottom() {

		},
		methods: {
			
			async userInfo() {
				const res = await this.$u.post('api/hotel/me?uid=' + uni.getStorageSync('uid'))
				this.list = res.data.buy
				console.log('请求成功userInfo', this.list)
			},
			
			
			
			goinfo(id, orederId) {
				uni.navigateTo({
					url: '/pages/site/meBuy?id=' + id + '&orederId=' + orederId
				})
			},

			// click(index, index1) {
			// 	if (index1 == 1) {
			// 		this.list.splice(index, 1);
			// 		this.$u.toast(`删除了第${index}个cell`);
			// 	} else {
			// 		this.list[index].show = false;
			// 		this.$u.toast(`收藏成功`);
			// 	}
				
			// },
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if (index != idx) this.list[idx].show = false;
				})
			},



			goBack(id) {
				console.log(id)
				uni.navigateBack({
					delta: 1
				})
			},



			image() {
				console.log(9999);
				uni.previewImage({
					urls: [...this.img],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						},
					},
				});
			},

			buy() {
				console.log('唤起支付')
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: String(Date.now()),
					nonceStr: 'A1B2C3D4E5',
					package: 'prepay_id=wx20180101abcdefg',
					signType: 'MD5',
					paySign: '',
					success: function(res) {
						console.log('success:' + JSON.stringify(res));
					},
					fail: function(err) {
						console.log('fail:' + JSON.stringify(err));
					}
				});

			},

			// 复制文本
			copy() {
				uni.setClipboardData({
					data: 'hello',
					success: function() {
						console.log('success');
						// this.$tools.msg('复制成功')
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100vh;
		// padding: 0 30rpx;
		background-color: #FFFFFF;


		.item {
			display: flex;
			padding: 20rpx;
		}

		// image {
		// 	width: 120rpx;
		// 	flex: 0 0 120rpx;
		// 	height: 120rpx;
		// 	margin-right: 20rpx;
		// 	border-radius: 12rpx;
		// }

		.title {
			text-align: left;
			font-size: 28rpx;
			color: #000000;
			margin: 20rpx 0 10rpx;
		}



		.header {
			width: 100%;
			height: 200rpx;
			line-height: 150rpx;
			display: flex;
			align-items: center;
			// padding-left: 10rpx;
			padding-top: 30rpx;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			background: #FFFFFF;

			.arrow {
				position: relative;
				display: inline-block;
			}

			.arrow::before {
				content: '';
				width: 10px;
				height: 10px;
				border: 0px;
				border-bottom: solid 2px #2C2C2C;
				border-left: solid 2px #2C2C2C;
				-ms-transform: rotate(45deg);
				-webkit-transform: rotate(45deg);
				transform: rotate(45deg);
				position: absolute;
				top: 50%;
				left: 0;
				margin-top: -4px;
				margin-left: 28rpx;
			}

			.title {
				margin: 0 auto;
			}
		}





		.left-box {

			.left-image {
				width: 120rpx;
				height: 120rpx;
				margin-right: 20rpx;
				overflow: hidden;
				border-radius: 60rpx !important;

				image {
					width: 100%;
					height: 100%;
					border-radius: 60rpx !important;
				}
			}
		}

		.money {
			width: 228rpx;
			height: 56rpx;
			padding: 0 33rpx;
			color: #54599B;
			font-size: 28rpx;

			.money-image {
				width: 30rpx;
				height: 30rpx;
				margin-right: 19rpx;
			}
		}



		.box-info {
			width: 100%;
			height: 138rpx;
			margin-top: 35rpx;
			padding: 0 30rpx;
			color: #FFFFFF;
			background-color: #4F5394;
			border-radius: 16rpx;

			.balance {
				width: 198rpx;
				height: 58rpx;
				border-radius: 29rpx;
				line-height: 58rpx;
				text-align: center;
				color: #4F5394;
				font-size: 30rpx;
				background-color: #FFFFFF;
			}
		}



		.me-shopping {
			width: 100%;
			height: 116rpx;
		}



		.box2 {
			width: 100%;
			height: 90rpx;
			color: #717171;
			line-height: 90rpx;
		}


		.user-info {
			width: 100%;
			height: 140rpx;
			// line-height: 100rpx;
			color: #232323;
			display: flex;
			align-items: center;
			border-radius: 10rpx;
			border-bottom: 1rpx solid #F8F8F8;

			.user-info-left {
				display: flex;
				align-items: center;
			}

			.user-image {
				width: 110rpx;
				height: 94rpx;
				border-radius: 10rpx;
				margin-right: 30rpx;

				image {
					border-radius: 10rpx;
				}
			}

			.sold-out {
				width: 160rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align: center;
				border-radius: 25rpx;
				color: #ECA700;
				background: rgba(236, 167, 0, .1);
			}
		}

		.user-info:last-child {
			border-bottom: 0;
		}

	}
</style>
